package com.ruoyi.system.controller;

import java.util.List;
import java.util.Map;

import com.ruoyi.web.controller.tool.JsonResult;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ZhuanjiaBiandonghistory;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.service.IZhuanjiaBiandonghistoryService;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ruoyi
 * @date 2024-08-06
 */
@Controller
@RequestMapping("/system/biandonghistory")
public class ZhuanjiaBiandonghistoryController extends BaseController
{
    private String prefix = "system/biandonghistory";

    @Autowired
    private IZhuanjiaBiandonghistoryService zhuanjiaBiandonghistoryService;

    @RequiresPermissions("system:biandonghistory:view")
    @GetMapping()
    public String biandonghistory()
    {
        return prefix + "/biandonghistory";
    }

    /**
     * 查询【请填写功能名称】列表
     */
    @RequiresPermissions("system:biandonghistory:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZhuanjiaBiandonghistory zhuanjiaBiandonghistory)
    {
        startPage();
        List<ZhuanjiaBiandonghistory> list = zhuanjiaBiandonghistoryService.selectZhuanjiaBiandonghistoryList(zhuanjiaBiandonghistory);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @RequiresPermissions("system:biandonghistory:export")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZhuanjiaBiandonghistory zhuanjiaBiandonghistory)
    {
        List<ZhuanjiaBiandonghistory> list = zhuanjiaBiandonghistoryService.selectZhuanjiaBiandonghistoryList(zhuanjiaBiandonghistory);
        ExcelUtil<ZhuanjiaBiandonghistory> util = new ExcelUtil<ZhuanjiaBiandonghistory>(ZhuanjiaBiandonghistory.class);
        return util.exportExcel(list, "【请填写功能名称】数据");
    }

    /**
     * 新增【请填写功能名称】
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存【请填写功能名称】
     */
    @RequiresPermissions("system:biandonghistory:add")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZhuanjiaBiandonghistory zhuanjiaBiandonghistory)
    {
        return toAjax(zhuanjiaBiandonghistoryService.insertZhuanjiaBiandonghistory(zhuanjiaBiandonghistory));
    }

    /**
     * 修改【请填写功能名称】
     */
    @RequiresPermissions("system:biandonghistory:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        ZhuanjiaBiandonghistory zhuanjiaBiandonghistory = zhuanjiaBiandonghistoryService.selectZhuanjiaBiandonghistoryById(id);
        mmap.put("zhuanjiaBiandonghistory", zhuanjiaBiandonghistory);
        return prefix + "/edit";
    }

    /**
     * 修改保存【请填写功能名称】
     */
    @RequiresPermissions("system:biandonghistory:edit")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZhuanjiaBiandonghistory zhuanjiaBiandonghistory)
    {
        return toAjax(zhuanjiaBiandonghistoryService.updateZhuanjiaBiandonghistory(zhuanjiaBiandonghistory));
    }

    /**
     * 删除【请填写功能名称】
     */
    @RequiresPermissions("system:biandonghistory:remove")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zhuanjiaBiandonghistoryService.deleteZhuanjiaBiandonghistoryByIds(ids));
    }

    @PostMapping("/findcustomlist")
    @ResponseBody
    public JsonResult<?> findcustomlist(@RequestParam("zhuanjiaid")String zhuanjiaid)
    {
        try{
            List<Map<String,Object>> list = zhuanjiaBiandonghistoryService.findCustomList(zhuanjiaid);
            return JsonResult.getSuccessResult(list);
        } catch (Exception e){
            return JsonResult.getErrorResult("查询变动历史失败");
        }
    }
}
